﻿@model BasicMis.Web.Models.master
@{
Layout = "~/Areas/WeiXin/Views/Shared/_Layout.cshtml";
}
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="~/Areas/WeiXin/Content/css/NewOrder.css">
@section JScript{	
<script src="//libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
<script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript"></script>
<script src="~/Areas/WeiXin/Content/js/jquery-ui.min.js"></script>
<script src="/Plugs/Common.js"></script>
<script src="https://cdn.bootcss.com/moment.js/2.22.1/moment.min.js"></script>
}
<style type="text/css">
	body {
		font-family: "Microsoft YaHei"!important;
	}
	.mui-checkbox iput[type=checkbox]:before,
	.mui-radio input[type=radio]:before {
		font-size: 22px;
	}
	.mui-checkbox input[type=checkbox]:checked:before,
	.mui-radio input[type=radio]:checked:before {
		color: #c9161d;
		font-size: 22px;
	}
	.mui-table-view:after {
		height: 0;
	}
	.mui-card-content-inner {
		padding: 10px;
	}
	.mui-card-content-inner:after {
		position: absolute;
		right: 0;
		bottom: 0;
		left: 15px;
		height: 1px;
		content: '';
		-webkit-transform: scaleY(.5);
		transform: scaleY(.5);
		background-color: #c8c7cc;
	}
	.mui-segmented-control.mui-segmented-control-inverted .mui-control-item.mui-active {
		border: none;
	}
	.mui-segmented-control.mui-scroll-wrapper .mui-control-item {
		padding: 0 0px 0 0px;
	}
	.mui-scroll-wrapper {
		top: -6px;
	}
	.mui-card {
		margin: 5px 10px 5px 10px;
	}
	.pwd-box input[type="tel"] {
		width: 99%;
		height: 40px;
		color: transparent;
		position: absolute;
		top: 0;
		left: 0;
		border: none;
		font-size: 18px;
		opacity: 0;
		z-index: 1;
		letter-spacing: 50px;
	}
	.fake-box {
		display: flex;
		justify-content: space-between;
		width: 100%;
	}
	.fake-box input {
		flex: 1;
		width: 40px;
		height: 40px;
		border: none;
		border-right: 1px solid #e5e5e5;
		text-align: center;
		font-size: 30px;
	}
	.fake-box input:nth-last-child(1) {
		border: none;
	}
	#m-zkk {
		width: 60%;
	}
	#zkkzf .p-yxrq {
		display: inline-block;
	}
	#zkkzf input {
		margin-left: 5px;
	}
	.TextSubject {
		font-size: 16px;
		font-weight: normal;
	}
	.mui-content .mui-table-view .mui-table-view-cell p,
	.mui-content #ul-input .mui-table-view-cell p {
		margin-left: 0
	}
	.m-zknr p {
		width: 100%;
		color: #666666;
		font-size: 14px;
	}
	.m-zknr {
		width: 60%;
		display: inline-block;
		vertical-align: middle;
	}
	.mui-first {
		padding: 7px 15px;
	}
	/*日历插件*/
	.ui-corner-all,
	.ui-corner-bottom,
	.ui-corner-right,
	.ui-corner-br {
		margin: auto;
		padding: 0;
		width: 100%;
	}
	.ui-datepicker-calendar thead {
		width: 95%;
		color: #f45446;
	}
	.ui-state-default,
	.ui-widget-content .ui-state-default,
	.ui-widget-header .ui-state-default {
		margin: auto;
		background: white;
		height: 30px;
		width: 30px;
		border: none;
		border-radius: 50%;
		text-align: center;
		line-height: 20px;
	}
	.ui-datepicker .ui-datepicker-header {
		background: #f45446;
		color: white;
		border: none;
		border-radius: 0;
	}
	.ui-widget-content .ui-state-active {
		background: #f45446;
		border-radius: 50%;
		line-height: 20px;
		color: white;
	}
	.ui-state-highlight,
	.ui-widget-content .ui-state-highlight {
		background: darkgray;
		color: white;
	}
	html .ui-button.ui-state-disabled:active {
		background: #f45446;
	}
	.ui-datepicker-calendar thead th {
		padding: 5px;
	}
	.ui-datepicker table {
		margin: 0 0 20px;
	}
	.ui-datepicker-year {
		float: left;
	}
	.ui-datepicker-month {
		float: right;
	}
	.ui-widget-header .ui-icon {
		background-image: none;
	}
	.ui-icon,
	.ui-widget-content .ui-icon {
		background-image: none;
	}
	.ui-icon {
		text-indent: 1px;
		color: white;
		height: 20px;
	}
	.ui-datepicker .ui-datepicker-prev span,
	.ui-datepicker .ui-datepicker-next span {
		margin-top: -10px;
	}
	.grey {
		color: #1e1e1e;
		background: #dcdcdc !important;
	}
	.span-zh {
		color: black;
		font-weight: bold;
	}
	.m-zknr p,
	.m-zknr p span {
		font-size: 12px;
	}
	.m-zknr p:nth-child(1) {
		margin-bottom: 5px;
	}
	.btn-negative {
		margin: auto;
		width: 80%;
	}
	.u-chouse {
		margin-bottom: 6%;
	}
	.ktHide{
		display: none;
	}
	button#ktGj,
	button#ktgg{
		display: inline-block;
		vertical-align: middle;
		padding:5px 20px;
		margin-left:8px;
		font-size: 10px; 
	}
	.btnKT{
		background: none;
		color: #1e1e1e
	}
	#yhqlist p{
		color:#ffffff
	}
	#yhqlist .voucher-amount p{
		color:#000000;
		font-weight:bold; 
	}
</style>
<header class="navbar">
	<a class="btn btn-link pull-left" href="javascript:window.history.go(-1)"> <i class="icon icon-m icon-l"></i> <span class="text-title ng-binding">返回</span> </a>
	<div class="title" id="item">
		家庭清洁
	</div>
</header>
<div id="Box" class="mui-content" data-ishu="1">
	<form action="/WeiXin/Default/CreateOrder" method="post" id="myform">
		<input type="hidden" id="isLogin" name="isLogin" value="@Model.IsLogin">
		<input type="hidden" id="CurCity" name="CurCity" value="@Model.CurCity">
		<input type="hidden" id="HourseID" name="HourseID" value="@(@ViewBag.K_House==null?" ":@ViewBag.K_House.ID)">
		<input type="hidden" id="UintMoney" name="UintMoney">
		<input type="hidden" id="ItemCode" name="ItemCode">
		<input type="hidden" id="ItemName" name="ItemName"> @*
		<ul class="list-group subscribe-top list-group-negative">*@ @{
			<div class="mui-card" style="margin-bottom:15px;">
				<div class="mui-card-content">
					<div class="mui-card-content-inner bolder-b" style="height:47px;">
						<div class="u-left fl">
							<span class="subscribe-top-title" style="font-size:16px;">服务项目:</span>
							<a class="TextSubject" href="#" id="fwxm">家庭清洁</a>
						</div>
						<div class="u-right fr">
							<span class="subscribe-top-title" style="font-size:16px;">标准价格:</span>
							<a class="TextSubject" href="#" id="bzjg">50元/小时</a>
						</div>
						<div class="clear"></div>
					</div>
					@*新增内容*@

					<div class="mui-card-content-inner" style="height:47px;">

						<div class="fl u-left">
							<span class="subscribe-top-title" style="font-size:16px;">标准收费:</span>
							<a class="TextSubject" href="#" id="bzsf">50元/小时</a>
						</div>
						<div class="fr u-right">
							<span class="subscribe-top-title" style="font-size:16px;">会员收费:</span>
							<a class="TextSubject" href="#" id="hysf"></a>
						</div>
						<div class="clear"></div>
					</div>
					<div class="mui-card-content-inner ktHide" style="height:47px;">
						<div class="fl">
							<span class="subscribe-top-title" style="font-size:16px;">规　　格:</span>
							<button type="button" class="mui-btn mui-btn-danger" id="ktgg">挂机</button>
							<button type="button" class="mui-btn mui-btn-danger" id="ktGj">柜机</button>
						</div>
						
						<div class="clear"></div>
					</div>

					<div class="mui-card-content-inner" id="yypersons" style="height:47px !important;">
						<span class="subscribe-top-title" style="font-size:16px;">预约人数：</span>
						<span class="js-group" style="vertical-align:central;">
                            <button class="btn js-minusCount" type="button"
                                    style="height:26px;width:26px;border-radius: 50%;text-align: center;"
                                    onclick="delPerson()">
                                -
                            </button>
                            <input type="tel" class="btn input-number"
                                   style="font-weight: bold;color: black;margin:0 0 0 10px;height:26px !important;width:24px;border: none;font-size: 20px !important;"
                                   value="1" name="needPersons" id="needPersons"
                                   onkeyup="this.value=this.value.replace(/\D/g,'')"
                                   onafterpaste="this.value=this.value.replace(/\D/g,'')">
                            <span id="needPersons"
                                  style="height:26px; margin-right:10px;font-size: 16px !important;">人员</span>

						<button class="btn js-plusCount" type="button" style="height:26px;width:26px;border-radius: 50%;text-align: center; " onclick="addPerson()">
                                +
                            </button>

						</span>
						<input type="hidden" id="maxuint" name="maxuint" value="">
					</div>
					<div class="mui-card-content-inner" style="text-align:left;height:47px !important;">
						<span class="subscribe-top-title" id="yyareaLabel" style="font-size:16px;">每人小时：</span>
						<span class="inline js-group" style="vertical-align:central;">
                            <button class="btn js-minusCount" type="button"
                                    style="height:26px;width:26px;border-radius: 50%;text-align: center;"
                                    onclick="del('homearea',1)">
                                -
                            </button>
                            <input type="tel" class="btn input-number"
                                   style="font-weight: bold;color: black;margin:0 0 0 10px; height:26px !important;width:24px;border: none;font-size: 20px !important;"
                                   value="1" name="homearea" id="homearea"
                                   onkeyup="this.value=this.value.replace(/\D/g,'')"
                                   onafterpaste="this.value=this.value.replace(/\D/g,'')">
                                <span id="uint"
                                      style="height:26px !important;margin-right:10px;margin-bottom:15px; font-size: 16px !important;">小时</span>
						<button class="btn js-plusCount" type="button" style="height:26px;width:26px;border-radius: 50%;text-align: center; " onclick="add('homearea', 'maxuint')">
                                    +
                                </button>
						</span>
						<input type="hidden" id="maxuint" name="maxuint" value="">
						
					</div>

				</div>
			</div>

			if (Model.IsLogin == true) {
			<div class="mui-card" style="margin-bottom:15px;">
				<div class="mui-card-content">
					<div class="mui-card-content-inner" onclick="OpenWin()">
						<span class="subscribe-top-title" style="display:inline-block;font-size:18px;">服务地址：</span>
						<a class="text-info" href="javascript:void(0);" onclick="OpenWin()" id="cityBtn" style="color:black; font-size:16px;font-weight:normal;">
							@if (ViewBag.K_House != null) { @ViewBag.K_House.Address; } else { @Html.Raw("请选择服务地址"); };
						</a>
						<span style="display:block; width:0;height:0;border-width:18px 10px 0;border-style:solid;border-color:#666 transparent transparent;position:absolute; top:25%;right:5px;"></span>
						<input class="no-padding " type="hidden" id="allAddress" value="@if(ViewBag.K_House!=null){@ViewBag.K_House.Address;}" /> @*
						<div class="pull-right">
							<i class="icon icon-m icon-r"></i>
						</div>
						*@
					</div>
					<div class="mui-card-content-inner" onclick="OpenWin1()">
						<span class="subscribe-top-title" style="display:inline-block;font-size:18px;">服务时间：</span>
						<a class="text-info text-info1" id="abc" href="javascript:void(0);" style="color:black;font-weight: bold;font-size:16px;">
							服务时间
						</a>
                        <input class="no-padding " type="hidden" id="hidServiceTime" value="" />
						<span style="display:block; width:0;height:0;border-width:18px 10px 0;border-style:solid;border-color:#666 transparent transparent;position:absolute; top:25%;right:5px;"></span>
					</div>
				</div>
			</div>
			}
			// 优惠券
			<ul class="mui-table-view"  style="margin:0 10px 15px 10px">
				<li class="mui-table-view-cell" id="li-yhq">
					<a href="javascript:showWindjq(true);" class="mui-navigate-right">
						<span class="span-left"></span><span style="font-weight: bold">选择代金券</span>
					</a>
				</li>
				<li class="mui-table-view-cell">
					<p class="ljPrice" style="color:#c9161d;font-weight: bold">代金券已扣：0元</p>
				</li>
			</ul>
			<ul class="mui-table-view mui-table-view-radio" id="ul-input" style="margin-bottom:15px;">
				<li class="mui-table-view-cell li-title">
					<span class="span-left"></span><span style="font-weight: bold">支付方式</span><span id="hyqx"></span>
				</li>
				<li class="mui-table-view-cell mui-first">
					<div class="mui-input-row mui-radio mui-right">
						<label for="wx"><span class="bg-wx"></span>微信支付</label>
						<input name="cardZheKou" onchange="CalculateZKPrice(this,'')" type="radio" id="wx" value="wx">
					</div>
				</li>
				<li class="mui-table-view-cell">
					<div class="mui-input-row mui-radio mui-right">
						<label><span class="bg-zk"></span>支付宝支付</label>
						<input name="cardZheKou" onchange="CalculateZKPrice(this,'')" type="radio" id="zf" value="zf" disabled="disabled">
					</div>
				</li>
			</ul>

			} @*
		</ul>
		*@
        <p><span style="color:red;font-size:medium;margin-left:10px;display:none;" id="cardTips">注：会员期止后余额按50元/小时计费</span></p>
		<button class="btn-negative btn-block" type="button" id="submit" onclick="return _HeDui(this);">
            确认支付
        </button>
		<div id="errorMsg"></div>
		<div class="subscribe-footer" style="position: fixed;left: 0;right: 0; bottom: 7%; max-width: 640px; margin: 0 auto;">
			<input type="hidden" id="spdCode_selected" value="zdg">
			<input type="hidden" id="spdId_selected" value="3">
			<input type="hidden" id="hidhysf" value="3">
			<input type="hidden" id="error" value="">
			<input type="hidden" id="MemberID" value="@Model.CurMember.MemberID">
			<input type="hidden" name="ItemCode" id="ItemCode" value="">
			<input type="hidden" id="Vouchers" value="" />
			<input type="hidden" id="serial_no" value="">
		</div>
	</form>
</div>
<div class="log js-log" id="log_city" style="display:none;">
	<div class="log-inbox">
		<div class="log-main">
			<div class="log-title">
				<em>选择地址</em>
				<a class="log-close js-close" href="javascript:void(0);" onclick="CloseWin();">关闭</a>
			</div>
			<div class="log-page">
				@{ if (Model.IsLogin == true) {
				<div id="Box" class="pb-50">
					<div class="address-top">
						<span class="btn btn-negative btn-block btn-outlined" onclick="javascript:hrefTz();" id="add">添加新地址</span>
					</div>

					@foreach (var t in Model.V_K_HouseList) {
					<ul class="list-group list-group-negative address " id="add@(t.ID)" onclick="WinSelect('@t.ID','@t.HCity','@t.Address','@t.ContactUserName','@t.ContactPhone');">
						<li class="list-group-item">
							<span class="">
                                            @t.ContactUserName
                                        </span>
							<span class="pull-right">@t.ContactPhone</span>
							<div style="line-height:21px; font-size:11px; color:#666">@t.HCity &nbsp;@t.Address</div>
						</li>
						<li class="list-group-item list-double">
							<span class="">
                                            <input id="isDef" type="radio" name="isDef" value="" @((t.IsDefault!=null&&t.IsDefault.Value) ? "checked='checked'" : "") onclick="setDef('@t.MemberID','@t.ID');" /> 默认地址
                                        </span>
							<span class="pull-right"><a href="javascript:;" onclick="editAdd(0,'@t.ID');"><i
                                    class="fa icon-pencil"></i> 编辑</a>  <a href="javascript:;"
                                                                           onclick="editAdd(1,'@t.ID');"><i
                                    class="fa icon-trash"></i> 删除</a>  </span>
						</li>
					</ul>
					}
				</div>
				} else {
				<div class="classify-small">
					@foreach (var t in Model.Citys) {
					<button class="btn js-city" type="button" onclick="WinSelectCity('@t.Text');">@t.Text</button> }
				</div>
				} }

			</div>
		</div>
		<div class="log-border"></div>
	</div>
</div>
<div id="voucherBox" style="display: none;">
	<div class="quick-voucher">
		<div class="btn-box">
			<strong class="header no-border fl">选择代金券</strong><button class="btn btn-primary btn-block fr" type="button" id="vocherSub" onclick="showWindjq(false);">确认</button>
			<div class="clear"></div>
		</div>
		<div id="yhqlistWap">
			<ul class="list-group list-group-negative no-margin-top" id="yhqlist"></ul>
		</div>
	</div>
</div>
<div id="m-timer" style="display: none;">
	<div class="m-timerwarp">
		<div class="u-timeheader">
			<span class="span-close" onclick="CloseWin1();"></span>
			<div class="clear"></div>
		</div>
		<input type="hidden" id="actualDate">
		<div class="datepicker"></div>
		<div class="u-chouse">
			<div class="u-guding">
				<div class="u-xzpc">
					<ul class="ul-sw">
						<p class="li-first">上午</p>
						<li>服务时间:6:00-12:00</li>
						<li>服务时间:7:00-12:00</li>
						<li>服务时间:8:00-12:00</li>
						<div class="clear"></div>
					</ul>
				</div>
				<div class="u-xzpc">
					<ul class="ul-xw">
						<p class="li-first">下午</p>
						<li>服务时间:14:00-20:00</li>
						<li>服务时间:14:00-19:00</li>
						<li>服务时间:14:00-18:00</li>
						<div class="clear"></div>
					</ul>
				</div>
			</div>
		</div>

		<div class="u-btn">
			<button class="btn-tj">确认</button> <button class="btn-gb">关闭</button>
		</div>
	</div>
</div>
<!-- 密码支付 -->
<div id="m-zfmmmark" style="display: none;">
	<div class="m-zfmmmarkwarp">
		<div class="u-close">
			<p class="fr" style="font-size:30px;margin: 5px 10px ;" onclick="CloseWin3()">x</p>
		</div>
		<br/>
		<span id="errmsg" style="color:red;"></span> 
		@*<button type="button" id="btn2" onclick="javascript: _HeDui();">确认提交</button> *@
	</div>
</div>
<div id="m-fxmark" style="display:none;">
	<div class="u-fxmakwarp">
		<a href="https://hongjimeng.net/WeiXin/HuoDong/ActivityDetailCZ">
			<img style="width:100%" src="/Areas/WeiXin/Content/images/ggao.jpg" alt="">
		</a>
		<div class="u-fxheader">
			<img src="/Areas/WeiXin/Content/images1/bg-fenxiang.png" alt="" />
		</div>
		<div class="u-close" style="font-size: 30px; color: white;" onclick="CloseWin4()">
			x
		</div>
	</div>
</div>
<!-- 红包展示 -->
<div id="m-hongBao" style="display:none">
	<div class="winBody2">
		<div class="receive1-bg1">
			<div class="receive1-head"><h1 class="AwardMoney"></h1></div>
			<div class="receive1-body"><p>恭喜您<br>成功领取<br>鸿基梦全体员工祝您<br>恭喜发财，大吉大利</p></div>
			<button class="receive1-but1">确定</button>
			<div class="receive1-bg2"></div>
		</div>	
	</div>
</div>
<script type="text/javascript">
	var itemCode = "",
		itemName = "";
	var minValue = 0;
	var custZK = 1;
	var kahaoNum = "";
	var nowPerson = 1;
	var yhjljPrice = 0;
	var text;
	var rq = "";
	var PayType = '';	
	var wait = 120;
	//验证码
	var _Code;
	var City = $('#CurCity').val();
	$(function() {
		//$("#pwd-input").focus(function(){
		//    alert("focus");
		//});
		chengeItem(request('typecode'), '@ViewBag.typename');
		defaultDay();
		getCardList();
		loadYhq();
		/*$.post('/WeiXin/Me/GetMemberValidDate', function (result) {
		    var json = eval('(' + result + ')');
		    if(json.success){
		        $("#hyqx").append("(会员期限:"+json.msg+")");
		    }
		});*/
	});
	//项目大类归属
	function belonging(){
		var code = $('#ItemCode').val(),
			ItemGroupCode
		if(code == 'JTQJ'){
			ItemGroupCode = 'QJL'
		}else if(code == 'CFBY' || code == 'BXBY' || code == 'BZQJ' || code == 'CDQJ' || code == 'JJBY' || code == 'SFQX' || code == 'WSJ' || code == 'XYBY' || code == 'YSJX' || code == 'CLQX'){
			ItemGroupCode = 'BYL'
		}else if(code == 'KTWX' || code == 'GDST' || code == 'MF' || code == 'CLQX' || code == 'YYJ'){
			ItemGroupCode = 'QTL'
		}
		return ItemGroupCode
	} 
	// 默认当天时间
	function defaultDay(){
		var  ItemGroupCode = belonging(),
			code = $('#ItemCode').val(),
			CurCity = $('#CurCity').val();
		$.ajax({
			url: '/appv2/order/GetCityOrderReceivingDateList/?city=' + CurCity + '&ItemGroupCode=' + ItemGroupCode + "&code=" + code,
			async: false,
			dataType: 'json',
			success: function(req) {
				var jsondata = req.jsondata;
				var sj = "14:00";
				//判断默认哪天
				$.each(jsondata,function(i){
					if(jsondata[i].State != 3) {
						rq = jsondata[i].ServiceTime
						return false
					}
				})
				if(rq == ""){
					text = "服务时间爆满"
				}else{
					text = [rq,sj]
				}
				var text1 = text
				text1 = text.toString().replace(/,/g, " ");
				$('.text-info1').text(text1)
				$('#hidServiceTime').val(text1)
			}
		})
	}
	function CalculatePrice() {
		var unitPrice = $('#UintMoney').val();
		var number = $('#homearea').val();
		$('#totalMoney').html(unitPrice * number + '元');
		$('#bzsf').html((unitPrice * number * nowPerson).toFixed(2) + '元');
		if(kahaoNum != null && kahaoNum != undefined && kahaoNum != '') {
			$('#hysf').html(((unitPrice * number * nowPerson * custZK) - yhjljPrice).toFixed(2) + '元');
		} else {
		    $('#hysf').html(((unitPrice * number * nowPerson) - yhjljPrice).toFixed(2) + '元');
		}
		$('#hidhysf').val((unitPrice * number * nowPerson * custZK).toFixed(2));
	}
	function add(docname, maxname) {
		var val = $("#" + docname + "").val();
		if(!checkMaxValue(val)) {
			return false;
		}
		var max = $("#" + maxname).val();
		if(max != 0 && parseInt(max) <= parseInt(val)) {
			$("#" + docname + "").val(max);
			return false;
		}
		$("#" + docname + "").val(++val);
		CalculatePrice();
	}
	function del(docname, min) {
		var val = $("#" + docname + "").val();
		if(!checkMinValue(val)) {
			return false;
		}
		if(val != min) {
			--val;
		}
		$("#" + docname + "").val(val);
		CalculatePrice();
	}
	function addPerson() {
		var dPerson = 1;
		var maxPerson = 10;
		nowPerson = $("#needPersons").val();
		if(nowPerson < maxPerson) {
			nowPerson++;
		}
		$("#needPersons").val(nowPerson);
		//$("#homearea").val(nowPerson * 4);
		CalculatePrice();
	}
	function delPerson() {
		var dPerson = 1;
		var maxPerson = 10;
		nowPerson = $("#needPersons").val();
		if(nowPerson > dPerson) {
			nowPerson--;
		}
		$("#needPersons").val(nowPerson);
		//$("#homearea").val(nowPerson * 4);
		CalculatePrice();
	}
	function checkMinValue(delValue) {
		if(itemCode == 'JTQJ') {
			if(delValue <= 4) {
				//alert(nowPerson+"人最低服务时长是"+nowPerson*4+"小时！")
				alert("单人服务时间4小时起！");
				return false;
			}
		} else {
			if(delValue <= minValue) {
				alert("最低" + minValue + $("#uint").html() + "起！");
				return false;
			}
		}
		return true;
	}
	function checkMaxValue(delValue) {
		if(itemCode == 'JTQJ') {
			if(delValue >= 6) {
				alert("单次服务时间太长，请分2次或多次下单！")
				return false;
			}
		}
		return true;
	}
	//加载价格
	function chengeItem(itemcode, itemname) {
		itemCode = itemcode;
		itemName = itemname;
		//价格详情链接拼接
		var city = $("#CurCity").val();

		if(!itemcode) {
			itemcode = 'JTQJ';
			itemname = '家庭清洁';
		}
		if(itemcode ==  'KTWX'){
			$('.ktHide').show()
			/* 空调种类选择 */
			$('.ktHide').find('button').eq(1).addClass('btnKT')
			$('.ktHide').find('button').click(function(){
			
				$(this).removeClass('btnKT').siblings('button').addClass('btnKT')
				if($(this).index() == 1){
					ktgggetPrice(itemcode)
				}else{
					ktgGjetPrice(itemcode)
				}
				
			})
		}else{
			$('.ktHide').hide()
		}
		if(itemcode ==  'YYJ'){
			YYJgetPrice(itemcode)
		}
		if(itemcode ==  'GDST'){
			GDSTgetPrice(itemcode)
		}
		$("#PriceHref").attr('href', '/App/SortContent/ItemInfo?ItemCode=' + itemcode + '&City=' + city);
		getAreaLabel(itemcode);

		$("#item").html(itemname);
		$("#ItemCode").val(itemcode);
		$("#ItemName").val(itemname);
		$('#fwxm').html(itemname);
		getPrice(itemcode);
	}
	//油烟机价格
	function YYJgetPrice(itemcode) {
		$.post("/WeiXin/Default/getPrice", {
			ItemCode: itemcode,
			city: $("#CurCity").val(),
			hid: $("#HourseID").val()
		},
		 function(result) {
			//加载价格  单位
			var json = eval('(' + result + ')');
			if(json.UintShow) {
				$("#UintMoney").val("220");
				CalculatePrice();
				$("#bzjg").html("220元/台");
			} else {
				alert("未获取价格信息");
			}
		});
	}
	//管道疏通价格
	function GDSTgetPrice(itemcode) {
		$.post("/WeiXin/Default/getPrice", {
			ItemCode: itemcode,
			city: $("#CurCity").val(),
			hid: $("#HourseID").val()
		},
		 function(result) {
			//加载价格  单位
			var json = eval('(' + result + ')');
			if(json.UintShow) {
				if($("#CurCity").val() == "广州"){
					$("#UintMoney").val("180");
					CalculatePrice();
					$("#bzjg").html("180元/台");
				}else{
					$("#UintMoney").val("120");
					CalculatePrice();
					$("#bzjg").html("120元/台");
				}
				
			} else {
				alert("未获取价格信息");
			}
		});
	}
	//空调柜机价格
	function ktgggetPrice(itemcode) {
		$.post("/WeiXin/Default/getPrice", {
			ItemCode: itemcode,
			city: $("#CurCity").val(),
			hid: $("#HourseID").val()
		},
		 function(result) {
			//加载价格  单位
			var json = eval('(' + result + ')');
			if(json.UintShow) {
				$("#UintMoney").val("200");
				CalculatePrice();
				$("#bzjg").html("200元/台");
			} else {
				alert("未获取价格信息");
			}
		});
	}
	//空调挂机价格
	function ktgGjetPrice(itemcode) {
		$.post("/WeiXin/Default/getPrice", {
			ItemCode: itemcode,
			city: $("#CurCity").val(),
			hid: $("#HourseID").val()
		},
		 function(result) {
			//加载价格  单位
			var json = eval('(' + result + ')');
			if(json.UintShow) {
				$("#UintMoney").val("260");
				CalculatePrice();
				$("#bzjg").html("260元/台");
			} else {
				alert("未获取价格信息");
			}
		});
	}
	//获取价格
	function getPrice(itemcode) {
		$.post("/WeiXin/Default/getPrice", {
			ItemCode: itemcode,
			city: $("#CurCity").val(),
			hid: $("#HourseID").val()
		}, function(result) {
			//加载价格  单位
			var json = eval('(' + result + ')');
			if(json.UintShow) {
				$("#UintMoney").val(json.UintMoney);
				$("#itemprice").html(json.UintShow);
				//$("#uint").html(json.Uint);
				$("#maxuint").val(json.UnitMax);
				$('#max').html("最高 " + json.UnitMax + json.Uint);
				CalculatePrice();
				if(itemcode == 'JTQJ') {
					//$("#maxhs").val(json.UnitMax);
					$('#maxtime').html("最高 " + json.UnitMax + json.Uint);
				} else {
					//$("#maxhs").val(0);
					$('#maxtime').html('');
				}
				if(json.itemtype == 'QJL') { //清洁类的显示  人数
					$("#yynum").hide();
				} else {
					$("#yynum").hide();
				}
				$("#bzjg").html(json.UintShow);
			} else {
				alert("未获取价格信息");
			}
		});
	}
	function getCardList() {
		$.post("/WeiXin/Default/getCardList", {}, function(result) {
			//加载价格  单位
			var json = eval('(' + result + ')');
			if(json.jsondata) {
				var list;
				var cList = "";
				var icount = 0;
				if (json.jsondata.length > 0)
				{
				    $('#cardTips').show();
				} else {
				    $('#cardTips').hide();
				}
				//获取折扣卡类型
				var iic = getCardType(request('typecode'));
				console.log('我的折扣卡类型是~~~~~~' + iic)
				$.each(json.jsondata, function(index, item) {
					var YouXiaoQi = item.YouXiaoQi.substring(0,10)
					if(iic == 1) {
						var cItem =
							'<li class="mui-table-view-cell mui-first">' +
							'<div class="mui-input-row mui-radio mui-right">' +
							'<label for="inp' + index + '">' +
							'<span class="bg-zkk"></span>' +
							'<div class="m-zknr">' +
                            '<p>会员期止: <span class="span-zh">' + YouXiaoQi + '</span></p>' +
							'<p><span style="margin-right: 15px;">会员折扣：<span' +
							'class="span-zh">' + (item.ZheKou).toFixed(1) + '折</span></span><span>余额：<span class="span-zh">' + item.ShengYuMoney + '元</span></span>' +
							'</p>' +
							'</div>' +
							'</label>' +
							'<input name="cardZheKou" onchange="CalculateZKPrice(this,' + item.KaHao + ')" type="radio" id="inp'+ index +'" value=\"' + item.ZheKou/10 + '\" >' +
							'</div>' +
							'</li>';
						cList += cItem;
					} else if(iic == 2) {
						var cItem =
							'<li class="mui-table-view-cell mui-first">' +
							'<div class="mui-input-row mui-radio mui-right">' +
							'<label for="inp' + index + '">' +
							'<span class="bg-zkk"></span>' +
							'<div class="m-zknr">' +
                            '<p>会员期止: <span class="span-zh">' + YouXiaoQi + '</span></p>' +
							'<p><span style="margin-right: 15px;">会员折扣：<span' +
							'class="span-zh">' + ((item.QXZheKou).toFixed(2) * 10).toFixed(1) + '折</span></span><span>余额：<span class="span-zh">' + item.ShengYuMoney + '元</span></span>' +
							'</p>' +
							'</div>' +
							'</label>' +
							'<input name="cardZheKou" onchange="CalculateZKPrice(this,' + item.KaHao + ')" type="radio" id="inp'+ index +'" value="' + item.QXZheKou + '">' +
							'</div>' +
							'</li>';
						cList += cItem;
					} else if(iic == 3) {
						var cItem =
							'<li class="mui-table-view-cell mui-first">' +
							'<div class="mui-input-row mui-radio mui-right">' +
							'<label for="inp' + index + '">' +
							'<span class="bg-zkk"></span>' +
							'<div class="m-zknr">' +
                            '<p>会员期止: <span class="span-zh">' + YouXiaoQi + '</span></p>' +
							'<p><span style="margin-right: 15px;">会员折扣：<span' +
							'class="span-zh">' + ((item.BYZheKou).toFixed(2) * 10).toFixed(1) + '"折</span></span><span>余额：<span class="span-zh">' + item.ShengYuMoney + '元</span></span>' +
							'</p>' +
							'</div>' +
							'</label>' +
							'<input name="cardZheKou" onchange="CalculateZKPrice(this,' + item.KaHao + ')" type="radio" id="inp'+ index +'" value="' + item.BYZheKou + '">' +
							'</div>' +
							'</li>';
						cList += cItem;
					} else if(iic == 5) {
						var cItem =
							'<li class="mui-table-view-cell mui-first">' +
							'<div class="mui-input-row mui-radio mui-right">' +
							'<label for="inp' + index + '">' +
							'<span class="bg-zkk"></span>' +
							'<div class="m-zknr">' +
                            '<p>会员期止: <span class="span-zh">' + YouXiaoQi + '</span></p>' +
							'<p><span style="margin-right: 15px;">会员折扣：<span' +
							'class="span-zh">' + ((item.CBLZheKou).toFixed(2) * 10).toFixed(1) + '</span></span><span>余额：<span class="span-zh">' + item.ShengYuMoney + '元</span></span>' +
							'</p>' +
							'</div>' +
							'</label>' +
							'<input name="cardZheKou" onchange="CalculateZKPrice(this,'+ item.KaHao +')" type="radio" id="inp'+ index +'" value="'+ item.CBLZheKou +'">' +
							'</div>' +
							'</li>';
						cList += cItem;
					}
					icount++;
					list = $(cList);					
				});
				$(".li-title").after(list);	
				$('.mui-first:first').find('input').trigger('click')
			} else {
				alert("未获取折扣卡信息");
			}
		});
	}
	function CalculateZKPrice(obj, kh) {
		var selDate = new Array(text)
		selDate = selDate.splice(',')[0][0]
	    cardValid = 0;
	    var unitPrice = $('#UintMoney').val();
	    var number = $('#homearea').val();
		//折扣卡不为空获取折扣cardValid (有效状态)
	    if (kh != null && kh != undefined && kh != '') {

	        $.post('/WeiXin/Me/GetCardValidDateTag?CardID=' + kh, function (result) {
	            var json = eval('(' + result + ')');
	            if (json.success) {
					var msg1 = moment().format(json.msg + ' 23:50:00')
					selDate = moment().format(selDate + ' 24:00:00')
					//如果折扣卡到期时间 在 选择服务时间之前 验证卡状态为0
					if(moment(msg1).isBefore(selDate)){
						cardValid = 0 
					}else{
						//选择时间在到期时间之后
						cardValid = json.Valid;
					}
					if (cardValid == 1){
						$("#hyqx").html("(会员期止:" + json.msg + ")");
					} else {
						$("#hyqx").html("(会员期止:<span style=\"color:red;\">到期</span>)");
					}
				
	            } else {
	                cardValid = json.Valid;
	            }
	            if (kh != null && kh != undefined && kh != '') {
	                kahaoNum = kh;
	                PayType = 'zk';
	            } else {
	                kahaoNum = '';
	            }
				//折扣的价格
	            if (obj != null && (!isNaN(obj.value))) {
	                if (cardValid == 1)
						{
							custZK = obj.value;
						} else {
							custZK = 1.0;
						}
				} else if (obj != null && (isNaN(obj.value))) {
						if (obj.value == 'zf') {
							PayType = 'zf';
							custZK = 1.0;
						} else if (obj.value == 'wx') {
							PayType = 'wx';
							custZK = 1.0;
						}
				} else {
					custZK = 1.0;
				}
				if (kh != null && kh != undefined && kh != '') {
	                $('#hysf').html(((unitPrice * number * nowPerson * custZK) - yhjljPrice).toFixed(2) + '元');
	            } else {
	                $('#hysf').html('');
	            }
	            $('#hidhysf').val((unitPrice * number * nowPerson * custZK).toFixed(2));
	        }).error(function(err){
				alert('网络异常正在刷新')
				window.location.reload()
			})
		//折扣卡为空
	    } else {
			if (obj != null && (isNaN(obj.value))) {
	            if (obj.value == 'zf') {
	                PayType = 'zf';
	                custZK = 1.0;
	            } else if (obj.value == 'wx') {
	                PayType = 'wx';
	                custZK = 1.0;
					$('#hyqx').html('');
	            }
			} else {
				custZK = 1.0;
	        }
			$('#hysf').html(((unitPrice * number * nowPerson * custZK) - yhjljPrice).toFixed(2) + '元');
            $('#hidhysf').val((unitPrice * number * nowPerson * custZK).toFixed(2));
	    }
	}
	//获取折扣卡类型
	function getCardType(itemtype) {
		var type = 0;
		if(itemtype == 'CBL' || itemtype == 'JTQJ' || itemtype == 'JTZF' || itemtype == 'KFQJ' || itemtype == 'KHQJ') {
			type = 1;
		}
		if(itemtype == 'CBLCB' || itemtype == 'KFBJCB' || itemtype == 'KHQJCB') {
			type = 5;
		} else if(itemtype == 'CLQX' || itemtype == 'DTQX' || itemtype == 'YSJX') { //窗帘清洗 地毯 饮水机
			type = 2;
		} else if (itemtype == 'CFBY' || itemtype == 'SFQX' || itemtype == 'BZQJ' || itemtype == 'BXBY' || itemtype == 'CDQJ' || itemtype == 'XYBY') { //厨房保养 沙发清洗 壁纸清洗
			type = 3;
		} else if(itemtype == 'WSJ') { //卫生间
			type = 3;
		} else if(itemtype == 'YYJ' || itemtype == 'KTWX') { //油烟机 空调清洗
			type = 3;
		} else if(itemtype == 'SCAZ') { //擦玻璃
			type = 3;
		} else if(itemtype == 'DBBY' || itemtype == 'JJBY' || itemtype == 'CBL') { //地板保养
			type = 3;
		} else if(itemtype == 'QT') { //其它
			type = 3;
		} else if(itemtype == 'GDST') { //其它
			type = 3;
		}
		return type;
	}
	//更换单位
	function getAreaLabel(itemtype) {
		var strName = "每人小时：";
		if(itemtype != 'DTQX') { //地毯清洗 选项
			$("#dttype").hide();
		} else {
			$("#dttype").show();
		}
		if(itemtype == 'CLQX') { //窗帘清洗
			strName = "预约斤数：";
		} else if(itemtype == 'CFBY' || itemtype == 'SFQX') { //厨房保养 沙发清洗
			strName = "预约套数：";
		} else if(itemtype == 'WSJ') { //卫生间
			strName = "预约间数：";
		} else if(itemtype == 'YYJ' || itemtype == 'KTWX') { //油烟机 空调清洗
			strName = "预约台数：";
		} else if(itemtype == 'SCAZ') { //擦玻璃
			strName = "玻璃扇数：";
		} else if(itemtype == 'DBBY' || itemtype == 'JJBY' || itemtype == 'KFBJCB' || itemtype == 'CBLCB' || itemtype == 'CBL' || itemtype=='BZQJ') { //地板保养
			strName = "预约面积：";
		} else if(itemtype == 'DTQX') { //地毯清洗
			strName = "地毯面积：";
		} else if(itemtype == 'QT') { //其它
			strName = "预约份数：";
		} else if(itemtype == 'GDST') { //管道疏通
			strName = "预约次数：";
		}
		else if (itemtype == 'CDQJ') { //床垫清洁
		    strName = "预约张数：";
		}
		$("#yyareaLabel").html(strName);
		if(itemtype == 'JTQJ' || itemtype == 'KHQJ') { //其它
			$("#homearea").val(4);
			$("#uint").html("小时");
			$("#gongju").show();
			$("#item_fwmj").show();
			$("#item_caboli").show();
			$("#yypersons").show();
		} else {
			$("#yypersons").hide();
		}
		var punit = "小时";
		switch(itemtype) {
			case 'DBBY':
				$("#homearea").val(20);
				minValue = 20;
				$("#uint").html("平方");
				break;
			case 'JJBY':
				$("#homearea").val(20);
				minValue = 20;
				$("#uint").html("平方");
				break;
			case 'CBLCB':
				$("#homearea").val(12);
				minValue = 12;
				$("#uint").html("平方");
				break;
			case 'KFBJCB':
				$("#homearea").val(30);
				minValue = 30;
				$("#uint").html("平方");
				break;
			case 'KHQJCB':
				$("#homearea").val(30);
				minValue = 30;
				$("#uint").html("平方");
				break;
			case 'SFQX':
				$("#homearea").val(2);
				minValue = 2;
				$("#uint").html("座");
				break;
			case 'DTQX':
				$("#homearea").val(3);
				minValue = 3;
				$("#uint").html("平方");
				break;
			case 'CLQX':
				$("#homearea").val(10);
				minValue = 10;
				$("#uint").html("斤");
				break;
			case 'CFBY':
				$("#homearea").val(1);
				minValue = 1;
				$("#uint").html("套");
				break;
			case 'WSJ':
				$("#homearea").val(1);
				minValue = 1;
				$("#uint").html("间");
				break;
			case 'JJBY':
				$("#homearea").val(1);
				minValue = 1;
				$("#uint").html("平方");
				break;
			case 'CBLCB':
				$("#homearea").val(1);
				minValue = 10;
				$("#uint").html("平方");
				break;
		    case 'BZQJ':
		        $("#homearea").val(10);
		        minValue = 10;
		        $("#uint").html("平方");
		        break;
			case 'YYJ':
				$("#homearea").val(1);
				minValue = 1;
				$("#uint").html("台");
				break;
			case 'XYBY':
				$("#homearea").val(1);
				minValue = 1;
				$("#uint").html("台");
				break;
			case 'KTWX':
				$("#homearea").val(1);
				minValue = 1;
				$("#uint").html("台");
				break;
		    case 'CDQJ':
		        $("#homearea").val(1);
		        minValue = 1;
		        $("#uint").html("张");
		        break;
			case 'QT':
				//$("#homearea").val(1);
				$("#uint").html("元");
				break;
		}
	}
	function _GetCode(s) {
		var tel = $('#Tel').val();
		if(tel == '') {
			alert('请输入您的手机号码！');
			return false;
		}
		var myreg = /^0?1[3|7|4|5|8][0-9]\d{8}$/;
		if(!myreg.test(tel)) {
			alert('请输入正确的手机号码！');
			return false;
		}
		$.post("/App/Public/GetMobileCode", {
			Tel: tel,
			Type: 1
		}, function(result) {
			var json = eval('(' + result + ')');
			if(json.success) {
				s.setAttribute("disabled", true);
				_Code = json.jsondata.Code;

				time(s);
				//alert("验证码发送成功，请查看手机短信");
			} else {
				alert(json.msg);
				$("#BtnGetCode").attr("disabled", false);
				$("#yzm").focus();
			}
		});
	}
	function time(btn) {
		if(wait == 0) {
			btn.removeAttribute("disabled");
			$('#BtnGetCode').html("获取验证码");
			wait = 60;
		} else {
			btn.setAttribute("disabled", true);
			$('#BtnGetCode').html(wait + "秒后再获取");
			wait--;
			setTimeout(function() {
				time(btn);
			}, 1000);
		}
	}
	//验证表单内容
	function _HeDui(that) {
		var Price = $("#hidhysf").val();
	    //获取值
		$(that).attr('disabled','')
	    var timer = $('.text-info1').text();
	    var address = $('#cityBtn').text();
	    timer = timer.trim(timer);
	    address = address.trim(address);
	    if (address == "请选择服务地址;") {
	        alert('请选择服务地址');
			$('#submit').removeAttr('disabled')
	        return;
	    };
	    if (timer == "服务时间") {
	        alert('请选择服务时间');
			$('#submit').removeAttr('disabled')
	        return;
	    };
	    if (PayType == 'zk') {
			var ItemGroupCode,
			code = $('#ItemCode').val()
			if(code == 'CFBY' || code == 'DBBY' || code == 'SFQX' || code == 'WSJ' || code == 'CBLCB' || code == 'XYBY'){
				ItemGroupCode = 'BYL'
			}else {
				ItemGroupCode = 'Other'
			}
			//判断是否是保养类型  价格是否大于200  显示支付 否则返回 
			console.log(ItemGroupCode)
			if(ItemGroupCode == 'BYL'){
				if(Number(Price) >= Number(200)){
					$("#m-zfmmmark").show();
				}else{
					alert('折扣卡金额必须大于200元')
					return
				}
			}else{
				$("#m-zfmmmark").show();
			}
			
	    }
		$("#errmsg").css("color", "red")
		$("#errmsg").html("正在生成订单...");
		var ContentName = null;
		if($("#ContentName")) {
			ContentName = $("#ContentName").val();
		}
		var Phone = $("#Tel").val();
		var City = $("#CurCity").val();
		var UserNum = $("#needPersons").val();
		var AllAddress = $("#allAddress").val();
		if(AllAddress) {
			Address = AllAddress;
		} else {
			alert('请选择服务地址！');
			$('#submit').removeAttr('disabled')
			return;
		}
		var serviceTime = $('#hidServiceTime').val();
		if (serviceTime == '') {
		    alert('请选择服务时间！');
			$('#submit').removeAttr('disabled')
		    return;
		}
		if(PayType == '') {
			alert('请选择支付方式！');
			$('#submit').removeAttr('disabled')
			return;
		}
		var ItemCode = $("#ItemCode").val();
		var ItemName = $("#ItemName").val();
		var PlanHours = $("#homearea").val();
		var PlanUnit = $("#uint").html();
		var HourseID = $("#HourseID").val();
		var Remark = $("#remark").val();
		var itemprice = $("#itemprice").html();
		var zjprice = 0;
		var Vouchers =$("#Vouchers").val();
		var Area = $("select[name=canton] option").not(function() {
			return !this.selected
		}).val();
		var Address = $("#street").val();

		if($('#isLogin').val() == false) {
			if(!ContentName) {
				alert('请输入联系人姓名！');
				return false;
			}
			if(Area == "-1") {
				alert('请选择区域！');
				return false;
			}
			if(!Address) {
				alert('请输入详细地址！');
				return false;
			}
			var tel = $('#Tel').val();
			if(tel == '') {
				alert('请输入您的手机号码！');
				return false;
			}
			var myreg = /^0?1[3|4|5|8][0-9]\d{8}$/;
			if(!myreg.test(tel)) {
				alert('请输入正确的手机号码！');
				return false;
			}
			if($('#Code').val() == '') {
				alert('请输入获取到的验证码！');
				return false;
			}
			if(_Code != $('#Code').val()) {
				alert('输入的验证不正确！');
				return false;
			}
		}
		//创建订单
		$.ajax({
			url:"/WeiXin/Default/CreateOrderNew",
			type : "POST",  //提交方式  
			data:{
				Phone: Phone,
				ContentName: ContentName,
				City: City,
				Area: Area,
				Address: Address,
				ItemCode: ItemCode,
				ItemName: ItemName,
				PlanHours: PlanHours,
				PlanUnit: PlanUnit,
				Price: Price,
				ServiceTime: serviceTime,
				UserNum:UserNum,
				HourseID: HourseID,
				Remark: "",
				itemprice: itemprice
			},
			success:function(result){
				var json = eval('(' + result + ')');
				console.log(result)
				if(json.success) {
					$("#errmsg").html("正在生成支付信息...");
					$.post("/Weixin/Default/Pay", {
						zjprice: zjprice,
						PayType: PayType,
						Vouchers: Vouchers,
						cardNo: kahaoNum
					}, 
					function(result) {
						var MemberID = $('#MemberID').val();
						var json = eval('(' + result + ')');
						if(json.success) {
							if(isEmpty(json.PayType) || json.PayType == 'zk') { //余额支付成功
								$("#errmsg").html("支付成功！");
								setTimeout(function() {
									CloseWin3();
									ShowWin4();
									fxHongbao(MemberID,json.jsondata.OrderId);
								}, 3000);
								$('#submit').removeAttr('disabled')
							} else {
								if(json.PayType == "wx") {
									window.location.href = "/WeiXin/Pay/WXPay?OrderID=" + json.OrderID + "";
								} else if(json.PayType == "zf") {
									console.log('支付宝支付!')
									window.location.href = "/WeiXin/Pay/ZFBPay?OrderID=" + json.OrderID + "";
								}
								$('#submit').removeAttr('disabled')
							}
						} else {
							alert(json.msg);
							$("#errmsg") = "";
							$("#errmsg").hide();
							$('#submit').removeAttr('disabled')
						}
					});
				} else {
			    	alert(json.msg);
			    	$("#errmsg") = "";
			    	$("#errmsg").hide();
					$('#submit').removeAttr('disabled')
				}
			},
			error:function(){
				alert('网络超时');
				$('#submit').removeAttr('disabled')
			}
		})
		if (PayType == 'zk') {
		    $("#m-zfmmmark").show();
		}
	
	}
	//支付完成调分享 成功后调红包接口
	function fxHongbao(MemberID,OrderID){
		wx.ready(function() {
			// wx.hideOptionMenu();
			wx.onMenuShareTimeline({
			    title: '分享立得5元优惠券',
				link: 'https://www.hongjimeng.net/appv2/share/evashare',
				imgUrl: 'https://hongjimeng.net/Areas/WeiXin/Content/images/logo.png',
				success: function() {
					$.ajax({
						url:"/appv2/share/evaShareState",
						type:"GET",
						data:{
							'Type':2,
							'memberid':MemberID,
							'orderid':OrderID,
							"shareState":"1"
						},
						dataType:"json",
						success:function(res){
							if(res.success == true){
								console.log(res)
								$('#m-fxmark').toggle();
								$('#m-hongBao').toggle();
								$('.AwardMoney').html(res.jsondata.AwardMoney + "元" + '<br>现金红包' );	
								$('.receive1-but1').click(function(){
									console.log('点击跳转待服务')
									location.href = "/WeiXin/Me/me_order"
								})
							}else{
								alert('领取失败')
							}
						}
					})
				},
				cancel: function() {
					// 用户取消分享后执行的回调函数
					// mui.toast('分享失败');
					alert('分享失败')
					return false;
				}
			});
			wx.onMenuShareAppMessage({
			    title: '分享立得5元优惠券',
			    desc: '分享立得5元优惠券',
				link: 'https://www.hongjimeng.net/appv2/share/evashare',
				imgUrl: 'https://hongjimeng.net/Areas/WeiXin/Content/images/logo.png',
				trigger: function(res) {
					// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
				},
				success: function(res) {
					$.ajax({
						url:"/appv2/share/evaShareState",
						type:"GET",
						data:{
							'Type':2,
							'memberid':MemberID,
							'orderid':OrderID,
							"shareState":"1"
						},
						dataType:"json",
						success:function(res){
							if(res.success == true){
								console.log(res)
								$('#m-fxmark').toggle();
								$('#m-hongBao').toggle();
								$('.AwardMoney').html(res.jsondata.AwardMoney + "元" + '<br>现金红包' );	
								$('.receive1-but1').click(function(){
									console.log('点击跳转待服务')
									location.href = "/WeiXin/Me/me_order"
								})
							}else{
								alert('领取失败')
							}
						}
					})
				},
				cancel: function(res) {
					// 用户取消分享后执行的回调函数
					// mui.toast('分享失败');
					alert('分享失败')
					return false;
				}
			});
		});
		wx.error(function(res){
    		// config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
			// mui.toast('分享接口调用失败')
			// alert('分享接口调用失败')
		});
	}
	// 优惠卷选择
	function selectDJQ(ID, tit, that ,Price) {
		$("#Vouchers").val("")
		$('.list-double').find('span').addClass('inverse')
		$(that).find('span').removeClass('inverse');
		// $(that).attr('checked', 'checked');
		var isCheck = $('#voucher_' + ID + '').attr('checked');
		if(isCheck == "checked") //取消选择
		{
			yhjljPrice = 0
			$('#li' + ID + ' span').addClass('inverse');
			$('#voucher_' + ID + '').removeAttr('checked', 'checked');
			$("#Vouchers").val("")
		} else //选择
		{
			yhjljPrice = Price
			$('#li' + ID + ' span').removeClass('inverse');
			$('#voucher_' + ID + '').attr('checked', 'checked');
			$("#Vouchers").val( ID ); //代金券编号增加

		}
	}
	//加载优惠券
	function loadYhq() {
		$.ajax({
			url:"/weixin/me/GetMemberKHDVouchersList?itemgroupcode=" + ItemCode,
			success:function(res){
				var json = eval('(' + res + ')');
				if(json.success) {
					var data = json.jsondata;
					// console.log(data)
					var _html = "";
					$.each(data, function(t, obj) {
						_html = _html + '<li class="list-group-item list-double" onclick="selectDJQ(' + obj.ID + ',\'' + obj.Title + '\',this,' + obj.Price + ')" id="li' + obj.ID + '"> <div  class="quick-voucher-labe">' +
							'<input type="radio" class="hide js-radio" name="voucher"  id="voucher_' + obj.ID + '"/>' +
							'<span class="icon icon-lbl icon-radio inverse"></span>' +
							'<div class="voucher-box" style="width: 90%">' +
							'<div class="voucher-time">' +
							'<p class="mb-5">' + obj.Title + '</p>' +
							'<p>' + obj.ItemGroupName + '</p>' +
							'</div>' +
							'<div class="voucher-amount-box">' +
							'<div class="voucher-amount">' +
							'<p>￥</p>' +
							'<p>' + obj.Price + '</p>' +
							'</div>' +
							'</div>' +
							'</div>' +
							'</div>' +
							'</li>';
					});
					if(data.length == 0) {
						_html = "<br/><p style='margin-left:1em;'>您没有优惠券！</p><br/>";
					}
					$("#yhqlist").html(_html);
				} else {
					alert('网络故障')
					window.location = "/WeiXin/Default/NewOrder"
				}
			}
		})
	}
	function setisdefault() {
		var isdefault = $("#isCaBoLi").attr('checked');
		if(!isdefault) {

		} else {
			alert("温馨提示：擦玻璃将按照1.5倍钟点工单价进行收费，费用在服务完成后收取！");
		}
	}
	function CloseWin() {
		$("#log_city").hide();
	}
	function OpenWin() {
		$("#log_city").show();
	}
	function CloseWin1() {
		$("#m-timer").hide();
	}
	function CloseWin3() {
		$("#m-zfmmmark").hide();
		$("#pwd-input").val("");
		console.log('关闭·········取消默认点击')
		$('#submit').removeAttr('disabled')
	}
	function showWindjq(show) {
		$("body,html").css({"overflow":"hidden"});
		$('body,html').animate({scrollTop:0},200)
		$('#yhqlistWap').css({"overflow-y":'auto'})
		if(show == true){
			$("#voucherBox").show();
			$("#voucherBox").scrollTop(0);
			return
		}else{
			$("#voucherBox").hide();
			$('.ljPrice').html('代金券已扣：' + yhjljPrice + "元")
			$('body').css({"overflow":'auto'})
			CalculatePrice();
			return
		}
	}
	function ShowWin4() {
		$("#m-fxmark").show();
	}
	function CloseWin4() {
		$("#pwd-input").val("");
		$("#m-fxmark").hide();
		window.location.replace("/WeiXin/Me/me_Order");
	}
	//  选择时间
	function OpenWin1() {
		$('.mui-first:first').find('input').attr("checked",false);
		$('body').css({"overflow":'hidden'});
		var ItemGroupCode = belonging(),
			code = $('#ItemCode').val(),
			timeMoment = moment().format('HH');
			timeDay = moment().format('DD');
		var $homearea = $('#homearea').val();
		var CurCity = $('#CurCity').val();
		
		$( ".datepicker" ).datepicker( "destroy" );
		$('.ul-sw li').removeClass('red');
		$('.ul-xw li').removeClass('red');
		$('.ul-jb li').removeClass('red');
		$("#m-timer").show();
		$.ajax({
			url: '/appv2/order/GetCityOrderReceivingDateList/?city=' + CurCity + '&ItemGroupCode=' + ItemGroupCode + "&code=" + code,
			dataType: 'json',
			async : false,  
			success: function(req) {	
				var natDays = [];
				var defaultDay;
				$( ".datepicker" ).datepicker( "destroy" );
				init();
				var jsondata = req.jsondata;
				var myDate = new Date();
				//判断当天时间
				if(myDate.getDate() == jsondata[0].ServiceTime.substr(8)) {
					var jsondatalength = jsondata.length - 1;
				} else {
					var jsondatalength = jsondata.length
				}
				//判断默认哪天
				$.each(jsondata,function(i,e){
						var ServiceTime = jsondata[i].ServiceTime;
						var ServiceTimes = new Array();
						ServiceTimes = ServiceTime.split('-');
						var yy = ServiceTimes[0];
						var mm = ServiceTimes[1];
						var dd = ServiceTimes[2];
						ServiceTimes.splice(0, 3, mm, dd, yy);
						if(jsondata[i].State != 3) {
							defaultDay = i
							return false
						}
				})
				$('.datepicker').datepicker({
					dateFormat: 'yy-mm-dd',
					altField: '#actualDate',
					showMonthAfterYear: true,
					dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
					firstDay: 1,
					monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
					minDate: 1,
					maxDate: jsondatalength,
					defaultDate: defaultDay,
					prevText: '<',
					nextText: '>',
					beforeShowDay: nationalDays,
					onSelect: function(selectedDate, inst) { //选择日期后执行的操作
						var sj = "";
						var rq = "";
						var sw = "sw";
						var State = "";
						//状态1
						function ulSw(style,time,sw) {
							text = [rq, sj];
							$('.ul-sw li').hide();
							$('.ul-xw li').hide();
							$('.ul-sw li').removeClass('grey');
							$('.ul-xw li').removeClass('grey');
							$('.ul-sw p').removeClass(style);
							$('.ul-xw p').removeClass(style);
							$(this).addClass(style)
							if(code == "JTQJ"){
								if(typeof(sw) == "undefined" ){
									console.log('这是下午~~~~~~~~~~~~~~~~~~~~~~~~选了')
									sj = '14:00';
									if(time == 6){
										$('.ul-xw li:first').show();
										$('.ul-xw li:first').addClass('grey');
									}else if(time == 5){
										$('.ul-xw li:eq(1)').show();
										$('.ul-xw li:eq(1)').addClass('grey');
									}else if(time == 4){
										$('.ul-xw li:last').show();
										$('.ul-xw li:last').addClass('grey');
									}
								}else{
									console.log('这是上午~~~~~~~~~~~~~~~~~~~~~~~~选了')
									if(time == 6){
										sj = '6:00';
										$('.ul-sw li:first').show();
										$('.ul-sw li:first').addClass('grey');
									}else if(time == 5){
										sj = '7:00';
										$('.ul-sw li:eq(1)').show();
										$('.ul-sw li:eq(1)').addClass('grey');
									}else if(time == 4){
										sj = '8:00';
										$('.ul-sw li:last').show();
										$('.ul-sw li:last').addClass('grey');
									}
								}
							}else{
								if(typeof(sw) == "undefined" ){
									sj = '14:00';
									$('.ul-xw li:last').show();
									$('.ul-xw li:last').addClass('grey');
								}else{
									sj = '8:00';
									$('.ul-sw li:last').show();
									$('.ul-sw li:last').addClass('grey');
								}
							}
							text.splice(1, 1, sj);
						}
						//提交
						function btnTj(actualDate) {
							var altField = $(actualDate).val();
							//获取会员期止时间
							var hyqz = $('#hyqx').html().replace('(会员期止:',"")
							hyqz = hyqz.replace(')',"")
							//获取到期字符串
							var hyqz1 = $('#hyqx').find('span').html()
							hyqz = hyqz.replace(')',"")
							text.splice(0, 1, altField);
							if(sj == "") {
								alert("请选择服务时间");
								return false;
							}
							//默认点第一张折扣卡
							$('.mui-first:first').find('input').trigger('click')
							var text1 = text
							text1 = text.toString().replace(/,/g, " ");
							$('#hidServiceTime').val(text1);
							$('.text-info1').text(text1);
							$('body').css({"overflow":'auto'});
							CloseWin1();
						}
						$.each(jsondata, function(i, e) {
							if(selectedDate == jsondata[i].ServiceTime) {
								State = jsondata[i].State
								return false;
							}
						})
						console.log(State)
						switch(State) {
							/* 正常接单 */
							case(1):
								if(timeMoment >= 18){
									console.log('超过限制第二天下午接单')
									$('body').off('click','.ul-sw p')
									$('body').on('click','.ul-xw p',function(event){
										event.stopPropagation();
										ulSw.call(this,'red',$homearea)
									})
									$('.ul-xw p').trigger('click')	
									$("body").off("click", ".btn-tj");
									$('body').on('click', '.btn-tj', function(event) {
										event.stopPropagation();
										btnTj.call(this,'#actualDate');
									})							
								}else{
									$('body').on('click','.ul-sw p',function(event){
										event.stopPropagation();
										ulSw.call(this,'red',$homearea,sw)
									})
									$('body').on('click','.ul-xw p',function(event){
										event.stopPropagation();
										ulSw.call(this,'red',$homearea)
									})
									$('.ul-sw p').trigger('click')
									$("body").off("click", ".btn-tj");
									$('body').on('click', '.btn-tj', function(event) {
										event.stopPropagation();
										btnTj.call(this, '#actualDate');
									})
								}
								break;
							/* 已经停止使用 */	
							case(2):
								init();
								$('.ul-sw p').addClass('grey');
								$('.ul-xw p').addClass('grey');
								$("body").off("click", ".btn-tj");
								break;
							/* 上午接单下午不能接单 */	
							case(4):
								init();
									$('.ul-xw p').off('click')
									$('body').on('click','.ul-sw p',function(event){
										event.stopPropagation();
										ulSw.call(this,'red',$homearea,sw)
									})
									$('.ul-sw p').trigger('click')
									$("body").off("click", ".btn-tj");
									$('body').on('click', '.btn-tj', function() {
										btnTj.call(this, '#actualDate');
									})
								break;
							/* 下午接单上午不能接单 */		
							case(5):
								console.log("下午能选上午不能");
								init();
								$('.ul-sw p').off('click')
								$('body').on('click','.ul-xw p',function(event){
									event.stopPropagation();
									ulSw.call(this,'red',$homearea)
								})
								$('.ul-xw p').trigger('click')
								$('body').on('click', '.btn-tj', function() {
									btnTj.call(this, '#actualDate');
								})
								break;
							default:
								init();
								$("body").off("click", ".ul-sw li");
								$("body").off("click", ".ul-xw li");
								$("body").off("click", ".ul-jb li");
								$("body").off("click", ".btn-tj");
								break;
						}
					}
				});
				/* 默认选择点击 */
				$('.ui-state-active').trigger('click')
				function nationalDays(date) {
					$.each(jsondata, function(i, e) {
						var ServiceTime = jsondata[i].ServiceTime;
						var ServiceTimes = new Array();
						ServiceTimes = ServiceTime.split('-');
						var yy = ServiceTimes[0];
						var mm = ServiceTimes[1];
						var dd = ServiceTimes[2];
						ServiceTimes.splice(0, 3, mm, dd, yy);
						if(jsondata[i].State == 3) {
							natDays.push(ServiceTimes);
						}
					})
					for(i = 0; i < natDays.length; i++) {
						if(date.getFullYear() == natDays[i][2] && date.getMonth() == natDays[i][0] - 1 &&
							date.getDate() == natDays[i][1]) {
							return [false, "natedays"];
						}
					}
					return [true, ''];
				}
				$('.btn-gb').click(function() {
					$('body').css({"overflow":'auto'});
					//默认点第一张折扣卡
					$('.mui-first:first').find('input').trigger('click')
					$("#m-timer").hide();
				})
			},
			error: function() {
				console.log('加载失败');
			}
		})
		
		function init() {
			$('.ul-xw p').removeClass('red');
		}
	}
	//检查客户客户输入
	function checkPayPass(kmm) {
		var lmID = $("#MemberID").val();
		if(lmID == null) {
			$("#errmsg").html("没有登陆，请重新登陆！")
		}
		$.post("/WeiXin/Default/checkCardPass", {
			km: lmID,
			pw: kmm
		},
		 function(result) {
			var json = eval('(' + result + ')');
			if(json.success) {
				_HeDui();
			} else {
				$("#errmsg").css("color", "red");
				$("#errmsg").html("支付密码错误，请重新输入！");
				$('#pwd-input').val("");
				$input.each(function(i,e) {
					$input.eq(i).val("");
				});
			}
		})
	}
	function WinSelect(homeId, city, address, name, phone) {
		setAddress(homeId, name, phone, city + address); //给地址赋值
		$("#CurCity").val(city);
		//$('#footer ul li.active').removeClass('active');
		//$('#footer ul li:eq(' + _Order + ')').addClass('active');
		$("#log_city").hide();
		getPrice($("#ItemCode").val());
		CloseWin();
	}
	function setAddress(Id, name, phone, address) {
		$("#cityBtn").html('<div class="address"><span class="name">' + name + '</span>&nbsp;&nbsp;<span class="phone">' + phone + '</span></div><div class="address cl"><span>' + address + '</span>');
		$("#HourseID").val(Id);
		$("#allAddress").val(address);
		getPrice($("#ItemCode").val());
	}
	function WinSelectCity(city) {
		$("#cityBtn").html(city);
		$("#CurCity").val(city);
		getArea(city);
		getPrice($("#ItemCode").val());
		CloseWin();
	}
	function getArea(CurCity) {
		$.post("/WeiXin/Me/getArea", {
			CurCity: CurCity
		}, function(result) {
			var json = eval('(' + result + ')');
			if(json.success) {
				$("#canton option").remove();
				//$("#canton").append("<option value='-1'>请选择区域</option>");
				var data = json.jsondata;
				if(data.lenght != 0) {
					$(data).each(function(index, obj) {
						$("#canton").append("<option value='" + obj.txt + "'>" + obj.txt + "</option>");
					});
				}
			}
		});
	}
	//设置默认地址
	function setDef(memberID, addressID) {

		$.post("/App/MemberInfo/SetDefaultAddress", {
				"MemberID": memberID,
				"HouseId": addressID
			},
			function(data) {
				var json = eval('(' + data + ')');
				if(json.success) {
					alert("设置成功！");
				} else {
					alert(json.msg);
				}
			});
	}
	function editAdd(type, addressID) {
        if (type == 0) {
            location.href = "EditAddress?addressID=" + addressID + "&typecode=" + itemCode + "&typename=" + escape(itemName) + "";
            return;
        }
        else (type == 1)
        {
            $.post("/App/MemberInfo/DelAddress", {"Id": addressID},
                function (data) {
                    var json = eval('(' + data + ')');
                    if (json.success) {
                        $("#add" + addressID + "").remove();
                    }
                    else {
                        alert(json.msg);
                    }
                });
        }
    }
	function OpenWin3() {
		var $input = $(".fake-box input");
		for(var i = 0;i<$input.length;i++){
			$input.eq(i).val("");
		}
		var timer = $('.text-info1').text();
		var address = $('#cityBtn').text();
		timer =  timer.trim(timer);
		address = address.trim(address);
		if(address == "请选择服务地址;"){
			alert('请选择服务地址');
			return;
		};
		if(timer == "服务时间"){
			alert('请选择服务时间');
			return;
		};	
		if(PayType == 'zk') {
			$("#m-zfmmmark").show();
			$("#pwd-input").trigger("click").focus();
		} else {
			_HeDui();
		}
	}
	function hrefTz() {
	    window.location.href = "/WeiXin/Default/EditAddress?City=" + City + "&itemCode=" + itemCode;
	}
</script>
<script>
	$(function() {
		var timestamp = '@ViewBag.Timestamp'; //时间戳
		var nonceStr = '@ViewBag.Noncestr'; //随机串
		var signature = '@ViewBag.Signature'; //签名
		wx.config({
			debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
			appId: 'wx47dc05e84b539c47', // 必填，公众号的唯一标识
			timestamp: timestamp, // 必填，生成签名的时间戳
			nonceStr: nonceStr, // 必填，生成签名的随机串
			signature: signature, // 必填，签名，见附录1
			jsApiList: ['scanQRCode', 'onMenuShareAppMessage', 'onMenuShareTimeline']
			// 必填，需要使用的JS接口列表，所有JS接口列表见附录2
		});
	});
</script>
